package com.climb.ssm;

import com.climb.ssm.service.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Administrator
 * @date 2021-06-07 15:23:21
 * @description
 * 测试spring配置细节之作用域scope
 * 默认singleton单例模式,只创建一个
 * protype每次请求都返回一个新的对象
 *
 */
public class SpingDemo2 {
    @Test
    public void scopeTest(){
        ApplicationContext ac= new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService as1 = ac.getBean("accountService", AccountService.class);
        AccountService as2 = ac.getBean("accountService", AccountService.class);
        System.out.println(as1 == as2);//true 相同对象
    }
}
